
class Config {
    baseURL: string
    timeout: number
	version:string
	platform:string
	imageBaseURL:string
	environment:Environment
	constructor(environment:Environment){
		this.environment = environment
		switch (environment) {
			case "dev":
				this.imageBaseURL = "https://osstoobs20210306.obs.cn-south-1.myhuaweicloud.com"
				this.baseURL = "https://devmall.gree.com"
				break
			case "test":
				this.imageBaseURL = "https://osstoobs20210306.obs.cn-south-1.myhuaweicloud.com"
				this.baseURL = "https://testingmall.gree.com"
				break
			case "uat":
				this.imageBaseURL = "https://gelimall.oss-cn-shenzhen.aliyuncs.com"
				this.baseURL = "https://uatmall.gree.com"
				break
			case "production":
				this.imageBaseURL = "https://gelimall.oss-cn-shenzhen.aliyuncs.com"
				this.baseURL = "https://fmall.gree.com"
				break
		}
		this.timeout = 3000
		this.version = "3.3.3"
		//// #ifdef APP-PLUS
		if (uni.getSystemInfoSync().platform == "android") {
			this.platform = "android"
		}else if (uni.getSystemInfoSync().platform == "ios") {
			this.platform = "ios"
		}else{
			this.platform = "unknown"
		}
		// #endif

		//#ifdef H5
		this.platform = "h5"
		// #endif

		// #ifdef MP-WEIXIN
		this.platform = "wx"
		// #endif

	}

	imageURL<T>(path:string):T{
		if (path.indexOf("http") != -1) {
			return path as T
		}
		return (this.imageBaseURL + path) as T
	}
}
type Environment = "dev" | "test" | "uat" | "production"

export let environment:Environment = import.meta.env.VITE_Environment ?? "dev"
//小程序 = 3eaa9fad1d148b5ea2b35a52bd6bbd74
const configs = {} as Record<Environment, Config>
configs["dev"] = new Config("dev")
configs["test"] = new Config("test")
configs["uat"] = new Config("uat")
configs["production"] = new Config("production")
export default  function getConfig(){
	return configs[environment]
};
